namespace RealtReview.DataAccess.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class up1 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.LastOnline", "User_Id", "dbo.ApplicationUsers");
            DropIndex("dbo.LastOnline", new[] { "User_Id" });
            CreateTable(
                "dbo.UserDetails",
                c => new
                    {
                        Id = c.Guid(nullable: false, identity: true),
                        DefaultCity = c.String(),
                        Nick = c.String(),
                        DateOfBirth = c.DateTime(),
                        Gender = c.Boolean(),
                        NofifyNewMessage = c.Boolean(nullable: false),
                        NofityNewComment = c.Boolean(nullable: false),
                        NotifyNewsOnSite = c.Boolean(nullable: false),
                        UserId = c.Guid(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            AddColumn("dbo.ApplicationUsers", "UserDetails_Id", c => c.Guid(nullable: false));
            CreateIndex("dbo.ApplicationUsers", "UserDetails_Id");
            AddForeignKey("dbo.ApplicationUsers", "UserDetails_Id", "dbo.UserDetails", "Id", cascadeDelete: true);
            DropColumn("dbo.ApplicationUsers", "UserId");
            DropColumn("dbo.ApplicationUsers", "DefaultCity");
            DropColumn("dbo.ApplicationUsers", "Nick");
            DropColumn("dbo.ApplicationUsers", "DateOfBirth");
            DropColumn("dbo.ApplicationUsers", "Gender");
            DropColumn("dbo.ApplicationUsers", "Rating");
            DropTable("dbo.LastOnline");
        }
        
        public override void Down()
        {
            CreateTable(
                "dbo.LastOnline",
                c => new
                    {
                        UserId = c.Guid(nullable: false),
                        LastOnlineDate = c.DateTime(nullable: false),
                        User_Id = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.UserId);
            
            AddColumn("dbo.ApplicationUsers", "Rating", c => c.Int(nullable: false));
            AddColumn("dbo.ApplicationUsers", "Gender", c => c.Boolean());
            AddColumn("dbo.ApplicationUsers", "DateOfBirth", c => c.DateTime());
            AddColumn("dbo.ApplicationUsers", "Nick", c => c.String());
            AddColumn("dbo.ApplicationUsers", "DefaultCity", c => c.String());
            AddColumn("dbo.ApplicationUsers", "UserId", c => c.Guid(nullable: false, identity: true));
            DropForeignKey("dbo.ApplicationUsers", "UserDetails_Id", "dbo.UserDetails");
            DropIndex("dbo.ApplicationUsers", new[] { "UserDetails_Id" });
            DropColumn("dbo.ApplicationUsers", "UserDetails_Id");
            DropTable("dbo.UserDetails");
            CreateIndex("dbo.LastOnline", "User_Id");
            AddForeignKey("dbo.LastOnline", "User_Id", "dbo.ApplicationUsers", "Id");
        }
    }
}
